<template>
  <div class="app">
    <h2>App Content</h2>
    <div class="nav">
      <router-link to="/about">关于</router-link>
      <router-link to="/home">home</router-link>

      <router-link to="/user/1">用户1</router-link>
      <router-link to="/user/2">用户2</router-link>
      <router-link to="/user/3">用户3</router-link>
      <router-link to="/user/4">用户4</router-link>
      <router-link to="/user/5">用户5</router-link>

      <div>
        <span @click="homeBtnClick">home带参数</span>
        <button @click="aboutBtnClick">关于带参数</button>
      </div>

      <div class="computed-demo">
        <span>FULLNAME：{{ fullName }}</span>
      </div>
    </div>
    <router-view></router-view>
  </div>
</template>

<script setup>
  import { useRouter } from 'vue-router'
  import { onMounted, computed } from "vue"

  const router = useRouter()


  const fullName = computed(() => {
    return 123
  })

  function homeBtnClick() {
    router.push({
      path: "/home",
      query: {
        title: "this is my home"
      }
    })    
  }

  function aboutBtnClick() {
    router.push({
      path: "/about",
      query: {
        name: "why",
        age: 18
      }
    })
  }

  onMounted(() => {
    console.log('onmounted111')
  })

</script>

<style scoped>
</style>